package org.xinjiang.data.migration.flush.convert;

import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.xinjiang.data.migration.flush.enums.*;
import org.xinjiang.data.migration.flush.utils.DefaultUtils;
import org.xinjiang.data.migration.hainan.entity.CorrectionteamFunctionary;

import java.util.ArrayList;
import java.util.Collection;


/**
 * 工作人员
 */
@Component
public class WorkingPersonnelConvert extends BaseConvert<org.xinjiang.data.migration.xinjiang.entity.SqjzGzry, CorrectionteamFunctionary> {

    @Override
    public CorrectionteamFunctionary convert(org.xinjiang.data.migration.xinjiang.entity.SqjzGzry gzry) {
        CorrectionteamFunctionary functionary = new CorrectionteamFunctionary();
        functionary.setSourceId(gzry.getId());
//        functionary.setRybm()//的需要生成
        functionary.setXm(DefaultUtils.getName(gzry.getXingming()));
//        functionary.setYwm()//没有
        functionary.setXb(String.valueOf(SexEnum.sex(gzry.getXingbie()).getId().intValue()));
        functionary.setCsrq(DefaultUtils.getDefCsrq(gzry.getChushengnianyue()));
        functionary.setSfzh(DefaultUtils.getDefSfzh(gzry.getShenfenzhenghao()));
        functionary.setMz(NationEnum.toCode(gzry.getMinzu()).getTargetCode());
        functionary.setZzmm(PoliticalOutlookEnum.toCode(gzry.getZhengzhimianmao()).getTargetCode());
        functionary.setHyzk(String.valueOf(MarriageEnum.toCode(gzry.getHunyinzhuangkuang()).getId().intValue()));
//        functionary.setZp()没有
        functionary.setXl(EducationalLevelEnum.toCode(gzry.getXueli()).getTargetCode());
        functionary.setZgxw(AcademicDegreeEnum.toCode(gzry.getZuigaoxuewei()).getTargetCode());
        functionary.setZy(SpecialityEnum.toCode(gzry.getZhiye()).getTargetCode());
        functionary.setSsjg(gzry.getLuruJigou());
        functionary.setJzjgbm(gzry.getLuruJigou());

        functionary.setZw(GzryCategoryEnum.toCode(gzry.getLeibie()).toTargetIdString());
        functionary.setRybz(OrganizationEnum.toCode(gzry.getRenyuanbianzhi()).getTargetCode());
        functionary.setCjgzsj(gzry.getCanjiagongzuodate());
        functionary.setSjhm(gzry.getShouji());
        functionary.setLxdh(gzry.getLianxidianhua());
        functionary.setDzyx(gzry.getDianziyouxiang());
        functionary.setZz(gzry.getLianxidizhi());
        functionary.setRyzt("1".equals(gzry.getShifouzaizhi()) ? "1" : "0");
        //更新人，更新时间，都没有
        functionary.setCreateBy(gzry.getLuruId());
        functionary.setCreateTime(gzry.getLts());
        return functionary;
    }


    @Override
    public Collection<CorrectionteamFunctionary> converts(Collection<org.xinjiang.data.migration.xinjiang.entity.SqjzGzry> ss) {
        Collection<CorrectionteamFunctionary> collection = new ArrayList<>();
        if (CollectionUtils.isEmpty(ss)) {
            return collection;
        }
        for (org.xinjiang.data.migration.xinjiang.entity.SqjzGzry s : ss) {
            collection.add(convert(s));
        }
        return collection;
    }
}
